/**
 * 后台账户管理路由
 */
const express = require('express');

// 用户中间件
const user = require('../../middleware/user');
// 后台账号管理路由
const accountApp = express();
// 账号列表页
accountApp.get('/',[user.lastLoginTime],(req,res)=>{
    let {user} = req;
    console.log(user)
    res.render('admin/account/index',{user,code:0})
});
accountApp.post('/edit',user.edit,(req,res)=>{
    if(req.affectedRows == 1){
        req.session.user = null;
        res.render('login',{msg:'密码修改成功，请重新登录'});
    }else{
        res.render('admin/account/index',{user:req.user,code:'修改失败'});
    }
});

module.exports = accountApp;